const link1 = document.querySelector('footer .link1')
const link2 = document.querySelector('footer .link2')
const link3 = document.querySelector('footer .link3')
const link4 = document.querySelector('footer .link4')

if (link1 && link2 && link3 && link4) {
  link1.addEventListener('click', function () {
    active()
    link1.classList.add('active')
    //   location.href = './index 1.html'
  })
  link2.addEventListener('click', function () {
    active()
    link2.classList.add('active')
    //   location.href = './classify.html'
  })
  link3.addEventListener('click', function () {
    active()
    link3.classList.add('active')
    //   location.href = './classify.html'
  })
  link4.addEventListener('click', function () {
    active()
    link4.classList.add('active')
    //   location.href = './my.html'
  })
  function active() {
    const active = document.querySelector('footer .active')
    active && active.classList.remove('active')
  }
}

// 封装轻提示
function tip(msg) {
  const toastElList = document.querySelector('#myToast')
  document.querySelector('.toast-body').innerHTML = msg
  const toast = new bootstrap.Toast(toastElList, {
    animation: true, // 开启过渡动画
    autohide: true, // 自动隐藏
    delay: 3000 // 3秒后隐藏
  })
  toast.show()
}

// 基地址
axios.defaults.baseURL = 'http://cba.itlike.com/public/index.php?s=/api/'

// 返回上一级
const back = document.querySelector('.back')
if (back) {
  back.addEventListener('click', function () {
    history.go(-1)
  })
}
